package com.itheima.service.impl;

import com.itheima.mapper.AccountMapper;
import com.itheima.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional(readOnly = false, isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
public class AccountServiceImpl implements AccountService {
    //引用类型 自动连接注入
    @Autowired
    private AccountMapper accountMapper;

    public void transfer(String sname, String tname, Double money) {
        accountMapper.outUpdate(sname,money);
        //int i=1/0;
        accountMapper.inUpdate(tname,money);
    }

    public void outUpdate(String tname, Double money) {
        accountMapper.outUpdate(tname,money);
    }
}
